package com.sinping.qh.query.lab;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jiahuaiqing
 * @create 2018/6/9
 */
@Data
public class UserLaboratoryQuery implements QueryParams, Serializable {
    private static final long serialVersionUID = -1531745016989272135L;
    static Map<String, String> aliasMap = new HashMap<>();
    static Map<String, Operator> operatorMap = new HashMap<>();

    /////////////////实验室列表使用/////////////////
    private String labName;
    private String unitId;
    private String buildingId;
    ///////////////////////////////////////////

    private String userId;
    private String managerUnitId;
    private String type;
    private String status;
    private String managerUnitName;
    private String userName;
    private String fullName;
    /**
     * 登录人负责实验室所在的单位集合
     */
    private List<String> unitIdList;
    /**
     * 登录人负责实验室所在的楼宇集合
     */
    private List<String> buildingIdList;

    static {
        /////////////////实验室列表使用/////////////////
        aliasMap.put("unitId", "manager_unit_id");
        aliasMap.put("labName","manager_lab_name");
        aliasMap.put("buildingId","lab_building_id");
        aliasMap.put("unitIdList", "manager_unit_id");
        aliasMap.put("buildingIdList","lab_building_id");
      ////////////////////////////////////////////

        aliasMap.put("userId", "user_id");
        aliasMap.put("managerUnitId", "manager_unit_id");
        aliasMap.put("type", "type");
        aliasMap.put("status", "status");
        aliasMap.put("managerUnitName","manager_unit_name");
        aliasMap.put("userName","user_name");
        aliasMap.put("fullName","full_name");
        operatorMap.put("userId", Operator.eq);
        operatorMap.put("managerUnitId", Operator.eq);
        operatorMap.put("type", Operator.eq);
        operatorMap.put("status", Operator.eq);
        operatorMap.put("managerUnitName",Operator.regex);
        operatorMap.put("userName",Operator.regex);
        operatorMap.put("fullName",Operator.regex);


        /////////////////实验室列表使用/////////////////
        operatorMap.put("unitId", Operator.eq);
        operatorMap.put("labName",Operator.regex);
        operatorMap.put("buildingId",Operator.eq);
        operatorMap.put("unitIdList",Operator.in);
        operatorMap.put("buildingIdList",Operator.in);
        ////////////////////////////////////////////
    }


    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }
}
